package com.wlyuan.open.domain.source;

import com.wlyuan.core.marker.NamedValue;
import com.wlyuan.core.marker.NamedValueMap;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.ToString;

import java.util.Map;

/**
 * @author yuanzheng
 */
@Getter
@ToString
@RequiredArgsConstructor
public class SourceStatus implements NamedValue<Integer> {
    private static final long serialVersionUID = 5127204921226131596L;
    private final String name;
    private final Integer value;

    public static final SourceStatus READY = new SourceStatus("READY", 0);
    public static final SourceStatus SUCCEED = new SourceStatus("SUCCEED", 1);
    public static final SourceStatus FAILED = new SourceStatus("FAILED", 2);

    private static final Map<Integer, SourceStatus> MAP = new NamedValueMap<>(SourceStatus.class);

    public static SourceStatus fromValue(Integer value) {
        return MAP.get(value);
    }
}
